package com.pro.control;

import com.pro.entity.JsonData;
import com.pro.entity.Product;
import com.pro.entity.UserOrder;
import com.pro.entity.UserOrderPlus;
import com.pro.service.ProductOrderListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author ：刘弘禹
 * @description：TODO
 * @date ：2021/11/12 10:33
 */
@Controller
@RequestMapping("/ProductOrder")
public class ProductOrderListController {
    @Autowired
    private ProductOrderListService productOrderListService;

    @RequestMapping("/queryOrder")
    @ResponseBody
    public JsonData queryOrder(UserOrderPlus userOrderPlus){
        List<UserOrder> userOrders = productOrderListService.queryOrder(userOrderPlus);
        return userOrders != null?JsonData.buildSuccess(userOrders):JsonData.buildError("服务器错误");
    }

    @RequestMapping("/getProduct")
    @ResponseBody
    public JsonData getProduct(Integer productId){
        List<Product> product = productOrderListService.getProduct(productId);
        return product != null?JsonData.buildSuccess(product):JsonData.buildError("服务器错误");
    }

    @RequestMapping("/delOrder")
    @ResponseBody
    public JsonData delOrder(Integer orderId){
        Boolean aBoolean = productOrderListService.delOrder(orderId);
        return aBoolean != null?JsonData.buildSuccess(aBoolean):JsonData.buildError("服务器错误");
    }

    @RequestMapping("/getStatus")
    @ResponseBody
    public JsonData getStatus(Integer orderStatus, Integer orderType){
        Integer status1 = productOrderListService.getStatus(orderStatus,orderType);
        return status1 != null?JsonData.buildSuccess(status1):JsonData.buildError("服务器错误");
    }
}
